package pe.gob.foncodes.ssa.bs.seguridad.domain;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import pe.gob.foncodes.ssa.bs.common.domain.EntidadBase;

/**
 *
 * @author Gcarlos
 */
@Entity
@Table(name = "GENERAL", catalog = "", schema = "SSA")
@NamedQueries({
    @NamedQuery(name = "General.findAll", query = "SELECT g FROM General g"),
    @NamedQuery(name = "General.findByTxtDominio", query = "SELECT g FROM General g WHERE UPPER(g.txtDominio) LIKE ?1 ORDER BY g.txtDominio, g.txtValor"),
    @NamedQuery(name = "General.findOnlyTxtDominio", query = "SELECT DISTINCT g.txtDominio FROM General g WHERE UPPER(g.txtDominio) LIKE ?1 ORDER BY g.txtDominio"),
    @NamedQuery(name = "General.findById", query = "SELECT g FROM General g WHERE g.id = ?1"),
    @NamedQuery(name = "General.findByTxtDominioEstado", query = "SELECT g "
                                                                + "FROM General g "
                                                                + "WHERE UPPER(g.txtDominio) =  UPPER(?1) "
                                                                + "AND g.flgActivo = ?2 "
                                                                + "ORDER BY g.txtDominio, g.txtValor"),
    @NamedQuery(name = "General.findByTxtDominioWS", query = "SELECT g "
                                                                + "FROM General g "
                                                                + "WHERE UPPER(g.txtDominio) =  UPPER(?1) "
                                                                + "ORDER BY g.txtDominio, g.txtValor"),
    @NamedQuery(name = "General.findTxtParametroEstado", query = "SELECT g"
                                                                + " FROM General g"
                                                                + " WHERE UPPER(g.txtParametro) = UPPER(?1)"
                                                                + " AND g.flgActivo = ?2"),
    @NamedQuery(name = "General.findByIdTxtDominio", query = "SELECT g"
                                                            + " FROM General g"
                                                            + " WHERE g.id = ?1"
                                                            + " AND g.txtDominio LIKE ?2"),
    @NamedQuery(name = "General.findByTxtDominioTxtValor", query = "SELECT g"
                                                            + " FROM General g"
                                                            + " WHERE UPPER(g.txtDominio) = UPPER(?1)"
                                                            + " AND UPPER(g.txtValor) = UPPER(?2)")
})
public class General extends EntidadBase implements Serializable {

    private static final long serialVersionUID = 1L;
    private String txtParametro;
    private String txtValor;
    private String flgActivo;
    private String txtDominio;
    private List<General> generalList;
    private General nidPadreGeneral;
    private List<SeguridadAdicional> seguridadAdicionalList;

    public General() {
    }

    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "NID_GENERAL", nullable = false, precision = 0, scale = -127)
    @SequenceGenerator(schema="SSA", name="SQ_GENERAL",sequenceName="SSA.SQ_GENERAL", allocationSize=1)
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SQ_GENERAL")
    @Override
    public Long getId() {
        return super.getId();
    }

    @Column(name = "NID_CONTROL_ACCESO_WEB", precision = 0, scale = -127)
    @Override
    public Long getNIdCtrlAccesoWeb() {
        return super.getNIdCtrlAccesoWeb();
    }
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "TXT_PARAMETRO", nullable = false, length = 50)
    public String getTxtParametro() {
        return txtParametro;
    }

    public void setTxtParametro(String txtParametro) {
        this.txtParametro = txtParametro;
    }

    @Basic(optional = false)
    @NotNull
    @Column(name = "TXT_VALOR", nullable = false, length = 50)
    public String getTxtValor() {
        return txtValor;
    }

    public void setTxtValor(String txtValor) {
        this.txtValor = txtValor;
    }

    @Basic(optional = false)
    @NotNull
    @Column(name = "FLG_ACTIVO", nullable = false)
    public String getFlgActivo() {
        return flgActivo;
    }

    public void setFlgActivo(String flgActivo) {
        this.flgActivo = flgActivo;
    }

    @Basic(optional = false)
    @NotNull
    @Column(name = "TXT_DOMINIO", nullable = false, length = 200)
    public String getTxtDominio() {
        return txtDominio;
    }

    public void setTxtDominio(String txtDominio) {
        this.txtDominio = txtDominio;
    }

    @OneToMany(mappedBy = "nidPadreGeneral")
    public List<General> getGeneralList() {
        return generalList;
    }

    public void setGeneralList(List<General> generalList) {
        this.generalList = generalList;
    }

    @JoinColumn(name = "NID_PADRE_GENERAL", referencedColumnName = "NID_GENERAL")
    @ManyToOne
    public General getNidPadreGeneral() {
        return nidPadreGeneral;
    }

    public void setNidPadreGeneral(General nidPadreGeneral) {
        this.nidPadreGeneral = nidPadreGeneral;
    }

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "general")
    public List<SeguridadAdicional> getSeguridadAdicionalList() {
        return seguridadAdicionalList;
    }

    public void setSeguridadAdicionalList(List<SeguridadAdicional> seguridadAdicionalList) {
        this.seguridadAdicionalList = seguridadAdicionalList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (getId() != null ? getId().hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof General)) {
            return false;
        }
        General other = (General) object;
        if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.getId().equals(other.getId()))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.gob.foncodes.ssa.bs.seguridad.domain.General[ getId()=" + getId() + " ]";
    }
}
